using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;

namespace CS2K2CatalogSystem
{
	/// <summary>
	/// Summary description for CatalogSystem.
	/// </summary>
	public class CatalogSystem : System.Web.Services.WebService
	{
		CatalogService catmgr = new CatalogService();

		public CatalogSystem()
		{
			//CODEGEN: This call is required by the ASP.NET Web Services Designer
			InitializeComponent();
		}

		#region Component Designer generated code
		
		//Required by the Web Services Designer 
		private IContainer components = null;
				
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if(disposing && components != null)
			{
				components.Dispose();
			}
			base.Dispose(disposing);		
		}
		
		#endregion

		[WebMethod]
		public DataSet GetCatalog(string catalogName)
		{
			return catmgr.GetCatalog(catalogName);
		}

		[WebMethod]
		public DataSet GetCatalogs(object lStartingRecord, object lNumRecords,ref object recInQuery)
		{
			return catmgr.GetCatalogs(lStartingRecord, lNumRecords,ref recInQuery);
		}

		[WebMethod]
		public DataSet GetRootCategories(string catalogName)
		{
			return catmgr.GetRootCategories(catalogName);
		}

		[WebMethod]
		public DataSet ChildCategories(string catalogName, string categoryName)
		{
			return catmgr.ChildCategories(catalogName, categoryName);
		}

		[WebMethod]
		public DataSet PropertiesToDisplayInList(string catalogName)
		{
			return catmgr.GetPropertiesToDisplayInList(catalogName);
		}

		[WebMethod]
		public DataSet RootProducts(string catalogName, string categoryName,  object lStartingRecord, object lRecordsToRetrieve, ref object plTotalRecordsInQuery)
		{
			return catmgr.RootProducts(catalogName, categoryName, lStartingRecord, lRecordsToRetrieve, ref plTotalRecordsInQuery);
		}

		[WebMethod]
		public DataSet CatalogRootProducts(string catalogName, object lStartingRecord, object lRecordsToRetrieve, ref object plTotalRecordsInQuery)
		{
			return catmgr.CatalogRootProducts(catalogName, lStartingRecord, lRecordsToRetrieve, ref plTotalRecordsInQuery);
		}

		[WebMethod]
		public DataSet GetLanguages()
		{
			return catmgr.GetLanguages(HttpContext.Current.Request.PhysicalApplicationPath+@"\languages.xml");
		}

		[WebMethod]
		public DataSet GetCurrencies()
		{
			return catmgr.GetCurrencies(HttpContext.Current.Request.PhysicalApplicationPath+@"\currencies.xml");
		}
		[WebMethod]
		public DataSet GetCatalogLanguages(string catalogName)
		{
			return catmgr.GetCatalogLanguages(catalogName);
		}

		[WebMethod]
		public DataSet GetDependentCatalogs(string catalogName)
		{
			return catmgr.GetDependentCatalogs(catalogName);
		}

		[WebMethod]
		public void DeleteCatalog(string catalogName)
		{
			catmgr.DeleteCatalog(catalogName);
		}

		[WebMethod]
		public void RegenerateFreeTextSearchIndex(string catalogName)
		{
			catmgr.RegenerateFreeTextSearchIndex(catalogName);
		}

		[WebMethod]
		public DataSet Search(string strSQLClause, string strFTSPhrase, string strCatalogsToSearch, string eClassTypeRequired, string strPropertiesToReturn, string strPropertyToSortOn, bool fSortAscending, string lStartingRecord, string lRecordsToRetrieve, string varLanguage, ref object plTotalRecordsInQuery)
		{
			return catmgr.Search(strSQLClause, strFTSPhrase, strCatalogsToSearch, eClassTypeRequired, strPropertiesToReturn, strPropertyToSortOn, fSortAscending, lStartingRecord, lRecordsToRetrieve, varLanguage, ref plTotalRecordsInQuery);
		}

		[WebMethod]
		public string SiteName()
		{
			return catmgr.SiteName();
		}

		[WebMethod]
		public DataSet GeProductDefintions()
		{
			return catmgr.GetProductDefintions();
		}

		[WebMethod]
		public DataSet GeCategoryDefintions()
		{
			return catmgr.GetCategoryDefintions();
		}

		[WebMethod]
		public void DeleteProduct(string catalogName, string ProductID)
		{
			catmgr.DeleteProdcut(catalogName, ProductID);
		}

		[WebMethod]
		public DataSet GetProduct(string catalogName, string ProductID)
		{
			return catmgr.GetProdcut(catalogName, ProductID);
		}

		[WebMethod]
		public DataSet GetProperties(string catalogName)
		{
			return catmgr.GetProperties(catalogName);
		}

		[WebMethod]
		public DataSet GetDefinitionProperties(string strDefinitionName)
		{
			return catmgr.GetDefinitionProperties(strDefinitionName);
		}

		[WebMethod]
		public void GetIdentifyingProperties(ref string ProductID, ref string VaraintID, string catalogName)
		{
			catmgr.GetIdentifyingProperties(ref ProductID, ref VaraintID, catalogName);
		}

		[WebMethod]
		public void SaveCatalogProperties(DataSet dsProperties, string catalogName)
		{
			catmgr.SaveCatalogProperties(dsProperties, catalogName);
		}

		[WebMethod]
		public void SaveProductProperties(DataSet dsProperties, string catalogName)
		{
			catmgr.SaveProductProperties(dsProperties, catalogName);
		}

		[WebMethod]
		public void SaveCategoryProperties(DataSet dsProperties, string catalogName)
		{
			catmgr.SaveCategoryProperties(dsProperties, catalogName);
		}

		[WebMethod]
		public void NewBaseCatalog(DataSet dsProperties, string catalogName)
		{
			catmgr.NewBaseCatalog(dsProperties, catalogName);
		}

		[WebMethod]
		public void NewVirtualCatalog(DataSet dsProperties, string catalogName)
		{
			catmgr.NewVirtualCatalog(dsProperties, catalogName);
		}

		[WebMethod]
		public void ImportXMLCatalog(string vrXML, bool fUpdateOnly, bool fRunSynchronously, bool fGenerateFullTextIndexes)
		{
			catmgr.ImportXMLCatalog(vrXML, fUpdateOnly, fRunSynchronously, fGenerateFullTextIndexes);
		}

		[WebMethod]
		public void ExportXMLCatalog(string vrXML, object strCatalogsToExport, bool fRunSynchronously, int eXMLFmt, string strLang)
		{
			catmgr.ExportXMLCatalog(vrXML, strCatalogsToExport, fRunSynchronously, eXMLFmt, strLang);
		}

		[WebMethod]
		public DataSet GetCategory(string catalogName, string categoryName)
		{
			return catmgr.GetCategory(catalogName, categoryName);
		}

		[WebMethod]
		public DataSet GetCategoryProducts(string catalogName, string categoryName, object lStartingRecord, object lRecordsToRetrieve, ref object plTotalRecordsInQuery)
		{
			return catmgr.GetCategoryProducts(catalogName, categoryName, lStartingRecord, lRecordsToRetrieve, ref plTotalRecordsInQuery);
		}
	}
}
